import 'package:flutter/material.dart';

import '../../../../res/myColors.dart';
import '../../employer/employer_page/employer_page_dialog/EmployerPageDialog.dart';

class SyMyListView extends StatelessWidget {
  const SyMyListView({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
        itemCount: 2,
        // 总共显示 20 项
        scrollDirection: Axis.vertical,
        // 列表垂直滚动
        reverse: false,
        // 是否倒序，false 表示从上往下滚动
        controller: ScrollController(),
        // 控制滚动位置（非必须）
        primary: false,
        // 如果为 true，不允许同时设置 controller
        physics: const NeverScrollableScrollPhysics(),
        // iOS 回弹效果
        shrinkWrap: true,
        // 整体内边距
        keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
        padding: EdgeInsets.zero,
      separatorBuilder: (context, index) => SizedBox(height: 5),
        itemBuilder: (context, index) {
          return getListItemView(context, index, 1);

        },
    );
  }
  Widget getListItemView(BuildContext context, int index, int type) {
    return Container(
      width: MediaQuery.of(context).size.width,
      padding: EdgeInsets.only(top: 8,),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius:BorderRadius.circular(5),
      ),
      child: Column(
        children: [
          // Visibility(
          //   visible: 2 == type, // true 显示，false 隐藏
          //   child: Container(
          //     width: MediaQuery.of(context).size.width,
          //     height: 30,
          //     child: Row(
          //       mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //       children: [
          //         Container(
          //           margin: EdgeInsets.only(left: 10),
          //           child: Text(
          //             '代发起定金合同',
          //             style: TextStyle(color: myColors.white),
          //           ),
          //         ),
          //         Container(
          //           margin: EdgeInsets.only(right: 10),
          //           child: Row(
          //             children: [
          //               Text('订单还剩', style: TextStyle(color: myColors.white)),
          //               CountdownTextSplit(timeStr: "23:59:59"),
          //               SizedBox(width: 10),
          //               CountdownTextSplit(timeStr: "8天:23:59:59"),
          //             ],
          //           ),
          //         ),
          //       ],
          //     ),
          //   ),
          // ),
          // SizedBox(height: 8),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                margin: EdgeInsets.only(left: 8),
                child: Row(
                  children: [
                    Text(
                      '家员母婴${type}',
                      style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.bold,
                        color: myColors.c_191919,
                      ),
                    ),
                    Container(
                      alignment: Alignment.center,
                      width: 5,
                      child: Text(
                        '|',
                        style: TextStyle(color: myColors.c_707070),
                      ),
                    ),
                    Text('门头区', style: TextStyle(color: myColors.c_707070)),
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(right: 8),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Text(
                      '12000-20000/时新',
                      style: TextStyle(
                        color: myColors.c_B51C21,
                        fontSize: 14,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
          SizedBox(height: 8),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Container(
                margin: EdgeInsets.only(left: 10),
                child: Row(
                  children: [
                    Text('住家', style: TextStyle(color: myColors.c_707070)),
                    Container(
                      alignment: Alignment.center,
                      width: 5,
                      child: Text(
                        '|',
                        style: TextStyle(color: myColors.c_707070),
                      ),
                    ),
                    Text('个人', style: TextStyle(color: myColors.c_707070)),
                    Container(
                      alignment: Alignment.center,
                      width: 5,
                      child: Text(
                        '|',
                        style: TextStyle(color: myColors.c_707070),
                      ),
                    ),
                    Text('B端', style: TextStyle(color: myColors.c_707070)),
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(right: 10),
                child: GestureDetector(
                  onTap: () {
                    print('>]按钮被点击了yyyyyyy');
                    EmployerPageDialog.dialog_Chargeback(context, (data) {});
                  },
                  child: Container(
                    width: 50,
                    // 按钮宽度
                    height: 20,
                    // 按钮高度
                    alignment: Alignment.center,
                    // 文字居中
                    decoration: BoxDecoration(
                      color: Colors.blue, // 按钮背景色
                      borderRadius: BorderRadius.circular(50), // 圆角
                      boxShadow: [
                        // 阴影效果（可选）
                        BoxShadow(
                          color: Colors.black.withOpacity(0.2),
                          blurRadius: 4,
                          offset: Offset(0, 2),
                        ),
                      ],
                      gradient: LinearGradient(
                        // 渐变背景（可选）
                        colors: [myColors.c_F89596, myColors.c_FF4142],
                        begin: Alignment.topLeft,
                        end: Alignment.bottomRight,
                      ),
                    ),
                    child: Text(
                      '去看看',
                      style: TextStyle(
                        color: Colors.white, // 字体颜色
                        fontSize: 10, // 加粗
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
          SizedBox(height: 8),
        ],
      ),
    );
  }
}